{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 用Tensorflow API：tf.keras搭建网络八股\n",
    "六步法：\n",
    "\n",
    "        import\n",
    "        x_train,y_train;x_test,y_test       #训练集、测试集\n",
    "        model = tf.keras.models.Sequential   #前向传播\n",
    "        model.compile                 #配置训练方法：优化器、损失函数、评测指标\n",
    "        model.fit                    #执行训练过程，告知训练集和测试集的输入特征和标签、每个Batch的大小、epoch迭代的次数\n",
    "        model.summary                 #打印网络的结构与参数统计\n",
    "#### model = tf.keras.models.Sequential([网络结构])--上层输出就是下层输入的顺序网络结构\n",
    "网络结构举例：  \n",
    "\n",
    "        拉直层：tf.keras.layers.Flatten()*把输入特征变成一维数组* \n",
    "        \n",
    "        全连接层：tf.keras.layers.Dense(神经元个数，activation=\"激活函数\"，kernel_regularizer=哪种正则化) \n",
    "                activation（字符串给出）：relu、softmax、sigmoid、tanh\n",
    "                kernel_regularizer：tf.keras.regularizers.l1()、tf.keras.regularizers.l2()\n",
    "                \n",
    "        卷积层：tf.keras.Conv2D(filters = 卷积核个数，kernel_size = 卷积核尺寸，strides = 卷积步长，padding = \"valid\" or \"same\")\n",
    "        \n",
    "        LSTM层：tf.keras.layers.LSTM()\n",
    "        \n",
    "#### model.compile(optimizer=优化器，loss=损失函数，metrics=[\"准确率\"])\n",
    "Optimizer可选：\n",
    "\n",
    "        'sgd' or tf.keras.optimizers.SGD(lr=学习率,momentum=动量参数)随机梯度下降\n",
    "        'adagrad' or tf.keras.optimizers.Adagrad(lr=)Adagrad算法-在SGD基础增加了二阶动量\n",
    "        'adadelta' or tf.keras.optimizers.Adadelta(lr=)\n",
    "        'adam' or tf.keras.optimizers.Adam(lr=,beta_1=0.9,beta_2=0.999)Adam算法-同时结合SGDM一阶动量和RMSProp二阶动量\n",
    "loss可选：\n",
    "\n",
    "        'mse' or tf.keras.losses.MeanSquaredError()均方误差\n",
    "        'sparse_categorical_crossentropy'tf.keras.losses.SparseCategoricalCrossentropy(from_logits=False)交叉熵损失函数（是否是原始输出）\n",
    "Metrics可选：\n",
    "\n",
    "        'accuracy':y_和y都是数值\n",
    "        'categorical_accuracy':y_和y都是独热码（概率分布）\n",
    "        'parse_categorical_accuracy':y_是数值，y是独热码\n",
    "       \n",
    "#### model.fit（训练集的输入特征，训练集的标签，batch_size=,epoch=,valodation_data=(测试集的输入特征，测试集的标签)/valodation_split=从训练集划分多少比列给测试集,valodation_freq=多少次epoch测试一次）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import tensorflow as tf\n",
    "from sklearn import datasets\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "x_train = datasets.load_iris().data\n",
    "y_train = datasets.load_iris().target\n",
    "\n",
    "np.random.seed(116)\n",
    "np.random.shuffle(x_train)\n",
    "np.random.seed(116)\n",
    "np.random.shuffle(y_train)\n",
    "tf.random.set_seed(116)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "model = tf.keras.models.Sequential([\n",
    "    tf.keras.layers.Dense(3, activation='softmax', kernel_regularizer=tf.keras.regularizers.l2())\n",
    "])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "model.compile(optimizer=tf.keras.optimizers.SGD(lr=0.1),\n",
    "              loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=False),\n",
    "              metrics=['sparse_categorical_accuracy'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train on 120 samples, validate on 30 samples\n",
      "Epoch 1/500\n",
      "120/120 [==============================] - 1s 5ms/sample - loss: 2.1962 - sparse_categorical_accuracy: 0.3500\n",
      "Epoch 2/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.8823 - sparse_categorical_accuracy: 0.6417\n",
      "Epoch 3/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 1.0519 - sparse_categorical_accuracy: 0.6500\n",
      "Epoch 4/500\n",
      "120/120 [==============================] - 0s 208us/sample - loss: 0.8097 - sparse_categorical_accuracy: 0.6333\n",
      "Epoch 5/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 1.0982 - sparse_categorical_accuracy: 0.6250\n",
      "Epoch 6/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.6229 - sparse_categorical_accuracy: 0.7167\n",
      "Epoch 7/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.9548 - sparse_categorical_accuracy: 0.6333\n",
      "Epoch 8/500\n",
      "120/120 [==============================] - 0s 108us/sample - loss: 0.5668 - sparse_categorical_accuracy: 0.7417\n",
      "Epoch 9/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.6024 - sparse_categorical_accuracy: 0.7167\n",
      "Epoch 10/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.5653 - sparse_categorical_accuracy: 0.7750\n",
      "Epoch 11/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.5925 - sparse_categorical_accuracy: 0.7250\n",
      "Epoch 12/500\n",
      "120/120 [==============================] - 0s 225us/sample - loss: 0.6456 - sparse_categorical_accuracy: 0.6667\n",
      "Epoch 13/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.5960 - sparse_categorical_accuracy: 0.7250\n",
      "Epoch 14/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.6188 - sparse_categorical_accuracy: 0.6750\n",
      "Epoch 15/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.5207 - sparse_categorical_accuracy: 0.8417\n",
      "Epoch 16/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.5884 - sparse_categorical_accuracy: 0.6833\n",
      "Epoch 17/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4988 - sparse_categorical_accuracy: 0.8083\n",
      "Epoch 18/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.5115 - sparse_categorical_accuracy: 0.7583\n",
      "Epoch 19/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.6111 - sparse_categorical_accuracy: 0.6917\n",
      "Epoch 20/500\n",
      "120/120 [==============================] - 0s 1ms/sample - loss: 0.7344 - sparse_categorical_accuracy: 0.6833 - val_loss: 0.6025 - val_sparse_categorical_accuracy: 0.5333\n",
      "Epoch 21/500\n",
      "120/120 [==============================] - 0s 110us/sample - loss: 0.4730 - sparse_categorical_accuracy: 0.8000\n",
      "Epoch 22/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.6484 - sparse_categorical_accuracy: 0.6750\n",
      "Epoch 23/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.5528 - sparse_categorical_accuracy: 0.7917\n",
      "Epoch 24/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.7129 - sparse_categorical_accuracy: 0.6500\n",
      "Epoch 25/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.5139 - sparse_categorical_accuracy: 0.7667\n",
      "Epoch 26/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4982 - sparse_categorical_accuracy: 0.8000\n",
      "Epoch 27/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 1.1382 - sparse_categorical_accuracy: 0.5917\n",
      "Epoch 28/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.5493 - sparse_categorical_accuracy: 0.7000\n",
      "Epoch 29/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.6210 - sparse_categorical_accuracy: 0.7000\n",
      "Epoch 30/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.5422 - sparse_categorical_accuracy: 0.7000\n",
      "Epoch 31/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4212 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 32/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.5288 - sparse_categorical_accuracy: 0.7000\n",
      "Epoch 33/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.6907 - sparse_categorical_accuracy: 0.6583\n",
      "Epoch 34/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4772 - sparse_categorical_accuracy: 0.8083\n",
      "Epoch 35/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.4436 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 36/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.5897 - sparse_categorical_accuracy: 0.7417\n",
      "Epoch 37/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.4435 - sparse_categorical_accuracy: 0.8250\n",
      "Epoch 38/500\n",
      "120/120 [==============================] - 0s 200us/sample - loss: 0.4061 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 39/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4785 - sparse_categorical_accuracy: 0.7583\n",
      "Epoch 40/500\n",
      "120/120 [==============================] - 0s 325us/sample - loss: 0.4328 - sparse_categorical_accuracy: 0.8417 - val_loss: 0.5688 - val_sparse_categorical_accuracy: 0.6000\n",
      "Epoch 41/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.4749 - sparse_categorical_accuracy: 0.7917\n",
      "Epoch 42/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.5713 - sparse_categorical_accuracy: 0.7167\n",
      "Epoch 43/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.5949 - sparse_categorical_accuracy: 0.7000\n",
      "Epoch 44/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3894 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 45/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.6079 - sparse_categorical_accuracy: 0.7333\n",
      "Epoch 46/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.6114 - sparse_categorical_accuracy: 0.6917\n",
      "Epoch 47/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.4088 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 48/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.4352 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 49/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.5262 - sparse_categorical_accuracy: 0.7417\n",
      "Epoch 50/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.4200 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 51/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.6255 - sparse_categorical_accuracy: 0.6583\n",
      "Epoch 52/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.8264 - sparse_categorical_accuracy: 0.6833\n",
      "Epoch 53/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4714 - sparse_categorical_accuracy: 0.8250\n",
      "Epoch 54/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.5078 - sparse_categorical_accuracy: 0.7500\n",
      "Epoch 55/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.4240 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 56/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4657 - sparse_categorical_accuracy: 0.8583\n",
      "Epoch 57/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3779 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 58/500\n",
      "120/120 [==============================] - 0s 208us/sample - loss: 0.3928 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 59/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3994 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 60/500\n",
      "120/120 [==============================] - 0s 242us/sample - loss: 0.4248 - sparse_categorical_accuracy: 0.8667 - val_loss: 0.9493 - val_sparse_categorical_accuracy: 0.5333\n",
      "Epoch 61/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.7443 - sparse_categorical_accuracy: 0.6833\n",
      "Epoch 62/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4022 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 63/500\n",
      "120/120 [==============================] - 0s 100us/sample - loss: 0.4407 - sparse_categorical_accuracy: 0.8500\n",
      "Epoch 64/500\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "120/120 [==============================] - 0s 117us/sample - loss: 0.4254 - sparse_categorical_accuracy: 0.8583\n",
      "Epoch 65/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4211 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 66/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.3679 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 67/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.4784 - sparse_categorical_accuracy: 0.7833\n",
      "Epoch 68/500\n",
      "120/120 [==============================] - 0s 100us/sample - loss: 0.6290 - sparse_categorical_accuracy: 0.6750\n",
      "Epoch 69/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3813 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 70/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3755 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 71/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3886 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 72/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.4446 - sparse_categorical_accuracy: 0.8167\n",
      "Epoch 73/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3933 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 74/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4546 - sparse_categorical_accuracy: 0.8583\n",
      "Epoch 75/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.3730 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 76/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3745 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 77/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3885 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 78/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.6013 - sparse_categorical_accuracy: 0.7083\n",
      "Epoch 79/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3682 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 80/500\n",
      "120/120 [==============================] - 0s 275us/sample - loss: 0.3648 - sparse_categorical_accuracy: 0.9333 - val_loss: 0.3486 - val_sparse_categorical_accuracy: 0.9667\n",
      "Epoch 81/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.5549 - sparse_categorical_accuracy: 0.7333\n",
      "Epoch 82/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.4028 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 83/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3798 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 84/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3935 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 85/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.4358 - sparse_categorical_accuracy: 0.8500\n",
      "Epoch 86/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4759 - sparse_categorical_accuracy: 0.8250\n",
      "Epoch 87/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4273 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 88/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.5257 - sparse_categorical_accuracy: 0.7500\n",
      "Epoch 89/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.6150 - sparse_categorical_accuracy: 0.687 - 0s 142us/sample - loss: 0.5146 - sparse_categorical_accuracy: 0.8000\n",
      "Epoch 90/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4159 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 91/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4119 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 92/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3800 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 93/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4675 - sparse_categorical_accuracy: 0.7917\n",
      "Epoch 94/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4614 - sparse_categorical_accuracy: 0.8167\n",
      "Epoch 95/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3742 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 96/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3666 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 97/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3699 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 98/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3871 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 99/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3991 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 100/500\n",
      "120/120 [==============================] - 0s 308us/sample - loss: 0.3707 - sparse_categorical_accuracy: 0.9333 - val_loss: 0.3488 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 101/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3660 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 102/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3743 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 103/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.4286 - sparse_categorical_accuracy: 0.8500\n",
      "Epoch 104/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4726 - sparse_categorical_accuracy: 0.8083\n",
      "Epoch 105/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3971 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 106/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3626 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 107/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3853 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 108/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.4205 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 109/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4696 - sparse_categorical_accuracy: 0.8333\n",
      "Epoch 110/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.4009 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 111/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4237 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 112/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3955 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 113/500\n",
      "120/120 [==============================] - 0s 108us/sample - loss: 0.3932 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 114/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3771 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 115/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4146 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 116/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3639 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 117/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3559 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 118/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4085 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 119/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4038 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 120/500\n",
      "120/120 [==============================] - 0s 250us/sample - loss: 0.3898 - sparse_categorical_accuracy: 0.9083 - val_loss: 0.3566 - val_sparse_categorical_accuracy: 0.8667\n",
      "Epoch 121/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3968 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 122/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.5416 - sparse_categorical_accuracy: 0.8083\n",
      "Epoch 123/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4635 - sparse_categorical_accuracy: 0.8500\n",
      "Epoch 124/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3970 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 125/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4089 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 126/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3783 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 127/500\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4521 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 128/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3612 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 129/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3534 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 130/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3624 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 131/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3767 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 132/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4185 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 133/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3814 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 134/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4230 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 135/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3636 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 136/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3685 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 137/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3573 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 138/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3876 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 139/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3797 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 140/500\n",
      "120/120 [==============================] - 0s 217us/sample - loss: 0.3610 - sparse_categorical_accuracy: 0.9167 - val_loss: 0.3956 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 141/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3889 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 142/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3711 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 143/500\n",
      "120/120 [==============================] - 0s 100us/sample - loss: 0.3936 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 144/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.4222 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 145/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3865 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 146/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3884 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 147/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3573 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 148/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3567 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 149/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3535 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 150/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3700 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 151/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3543 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 152/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3525 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 153/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3923 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 154/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3644 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 155/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3598 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 156/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3713 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 157/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3599 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 158/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3831 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 159/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4198 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 160/500\n",
      "120/120 [==============================] - 0s 225us/sample - loss: 0.3753 - sparse_categorical_accuracy: 0.9083 - val_loss: 0.3352 - val_sparse_categorical_accuracy: 0.9667\n",
      "Epoch 161/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3496 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 162/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3552 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 163/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3585 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 164/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3939 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 165/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3553 - sparse_categorical_accuracy: 0.9750\n",
      "Epoch 166/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4774 - sparse_categorical_accuracy: 0.8167\n",
      "Epoch 167/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3585 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 168/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3671 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 169/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3551 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 170/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3679 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 171/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3501 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 172/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3583 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 173/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3850 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 174/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3711 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 175/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.5982 - sparse_categorical_accuracy: 0.7583\n",
      "Epoch 176/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4060 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 177/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3808 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 178/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3528 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 179/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3529 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 180/500\n",
      "120/120 [==============================] - 0s 242us/sample - loss: 0.5415 - sparse_categorical_accuracy: 0.8000 - val_loss: 0.3710 - val_sparse_categorical_accuracy: 0.8667\n",
      "Epoch 181/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3991 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 182/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3712 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 183/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4376 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 184/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.3740 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 185/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3531 - sparse_categorical_accuracy: 0.9750\n",
      "Epoch 186/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4468 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 187/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3520 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 188/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3960 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 189/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3752 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 190/500\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3450 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 191/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3676 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 192/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3965 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 193/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.4040 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 194/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3535 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 195/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3798 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 196/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3599 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 197/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3632 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 198/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3789 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 199/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3995 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 200/500\n",
      "120/120 [==============================] - 0s 267us/sample - loss: 0.3566 - sparse_categorical_accuracy: 0.9333 - val_loss: 0.3405 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 201/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3695 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 202/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3705 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 203/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3659 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 204/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3444 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 205/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.3843 - sparse_categorical_accuracy: 0.937 - 0s 208us/sample - loss: 0.3482 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 206/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3541 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 207/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3461 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 208/500\n",
      "120/120 [==============================] - 0s 92us/sample - loss: 0.4319 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 209/500\n",
      "120/120 [==============================] - 0s 83us/sample - loss: 0.3794 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 210/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4089 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 211/500\n",
      "120/120 [==============================] - 0s 208us/sample - loss: 0.4438 - sparse_categorical_accuracy: 0.8417\n",
      "Epoch 212/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3817 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 213/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3611 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 214/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3471 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 215/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3721 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 216/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3789 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 217/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3548 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 218/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3957 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 219/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3922 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 220/500\n",
      "120/120 [==============================] - 0s 250us/sample - loss: 0.4800 - sparse_categorical_accuracy: 0.8250 - val_loss: 0.3715 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 221/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3449 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 222/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3515 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 223/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3992 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 224/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4384 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 225/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4206 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 226/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3515 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 227/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3643 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 228/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3677 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 229/500\n",
      "120/120 [==============================] - 0s 100us/sample - loss: 0.3581 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 230/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3595 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 231/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4021 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 232/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3488 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 233/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.4141 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 234/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3510 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 235/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3453 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 236/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3707 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 237/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3780 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 238/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3629 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 239/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3612 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 240/500\n",
      "120/120 [==============================] - 0s 250us/sample - loss: 0.3823 - sparse_categorical_accuracy: 0.9333 - val_loss: 0.3478 - val_sparse_categorical_accuracy: 0.9000\n",
      "Epoch 241/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3899 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 242/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4695 - sparse_categorical_accuracy: 0.8167\n",
      "Epoch 243/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3549 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 244/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4236 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 245/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4944 - sparse_categorical_accuracy: 0.8583\n",
      "Epoch 246/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3543 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 247/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3524 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 248/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3801 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 249/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3485 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 250/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3434 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 251/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3485 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 252/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3454 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 253/500\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3492 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 254/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3815 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 255/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.4077 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 256/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3796 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 257/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3603 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 258/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3593 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 259/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3550 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 260/500\n",
      "120/120 [==============================] - 0s 250us/sample - loss: 0.3702 - sparse_categorical_accuracy: 0.9333 - val_loss: 0.3728 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 261/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3443 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 262/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3642 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 263/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3592 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 264/500\n",
      "120/120 [==============================] - 0s 108us/sample - loss: 0.3484 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 265/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.3281 - sparse_categorical_accuracy: 1.000 - 0s 108us/sample - loss: 0.3374 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 266/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3543 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 267/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3952 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 268/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3469 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 269/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4562 - sparse_categorical_accuracy: 0.8417\n",
      "Epoch 270/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3673 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 271/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3751 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 272/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4066 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 273/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3520 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 274/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3508 - sparse_categorical_accuracy: 0.9750\n",
      "Epoch 275/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4247 - sparse_categorical_accuracy: 0.8500\n",
      "Epoch 276/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.5184 - sparse_categorical_accuracy: 0.8000\n",
      "Epoch 277/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3586 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 278/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.4024 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 279/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3472 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 280/500\n",
      "120/120 [==============================] - 0s 233us/sample - loss: 0.3479 - sparse_categorical_accuracy: 0.9417 - val_loss: 0.5195 - val_sparse_categorical_accuracy: 0.6667\n",
      "Epoch 281/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.5396 - sparse_categorical_accuracy: 0.7750\n",
      "Epoch 282/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3576 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 283/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4066 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 284/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3588 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 285/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4913 - sparse_categorical_accuracy: 0.8417\n",
      "Epoch 286/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3891 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 287/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3614 - sparse_categorical_accuracy: 0.9750\n",
      "Epoch 288/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3402 - sparse_categorical_accuracy: 0.9833\n",
      "Epoch 289/500\n",
      "120/120 [==============================] - 0s 100us/sample - loss: 0.3814 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 290/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3901 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 291/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3999 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 292/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3704 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 293/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3493 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 294/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3948 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 295/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4169 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 296/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3815 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 297/500\n",
      "120/120 [==============================] - 0s 108us/sample - loss: 0.3795 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 298/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3618 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 299/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3718 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 300/500\n",
      "120/120 [==============================] - 0s 258us/sample - loss: 0.3682 - sparse_categorical_accuracy: 0.9333 - val_loss: 0.3514 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 301/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3612 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 302/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.5295 - sparse_categorical_accuracy: 0.750 - 0s 125us/sample - loss: 0.4212 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 303/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3701 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 304/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.3652 - sparse_categorical_accuracy: 0.843 - 0s 167us/sample - loss: 0.3714 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 305/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3543 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 306/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3445 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 307/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3452 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 308/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3441 - sparse_categorical_accuracy: 0.9833\n",
      "Epoch 309/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3593 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 310/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3656 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 311/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3575 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 312/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3515 - sparse_categorical_accuracy: 0.9750\n",
      "Epoch 313/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3453 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 314/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.3536 - sparse_categorical_accuracy: 0.968 - 0s 133us/sample - loss: 0.3416 - sparse_categorical_accuracy: 0.9583\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 315/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3368 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 316/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4223 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 317/500\n",
      "120/120 [==============================] - 0s 208us/sample - loss: 0.3694 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 318/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3409 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 319/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3643 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 320/500\n",
      "120/120 [==============================] - 0s 233us/sample - loss: 0.3563 - sparse_categorical_accuracy: 0.9500 - val_loss: 0.6103 - val_sparse_categorical_accuracy: 0.6000\n",
      "Epoch 321/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3852 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 322/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3413 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 323/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3346 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 324/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3535 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 325/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3591 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 326/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3533 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 327/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3399 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 328/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.4023 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 329/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3758 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 330/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3763 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 331/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3627 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 332/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3408 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 333/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3571 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 334/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3856 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 335/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.4155 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 336/500\n",
      "120/120 [==============================] - 0s 108us/sample - loss: 0.5168 - sparse_categorical_accuracy: 0.7917\n",
      "Epoch 337/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3682 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 338/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3524 - sparse_categorical_accuracy: 0.9750\n",
      "Epoch 339/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.5209 - sparse_categorical_accuracy: 0.781 - 0s 158us/sample - loss: 0.3811 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 340/500\n",
      "120/120 [==============================] - 0s 200us/sample - loss: 0.3978 - sparse_categorical_accuracy: 0.8833 - val_loss: 0.4761 - val_sparse_categorical_accuracy: 0.8000\n",
      "Epoch 341/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3589 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 342/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3607 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 343/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3863 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 344/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3998 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 345/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3920 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 346/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4703 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 347/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4195 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 348/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3537 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 349/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3494 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 350/500\n",
      "120/120 [==============================] - 0s 108us/sample - loss: 0.3398 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 351/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3429 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 352/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3463 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 353/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3714 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 354/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3735 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 355/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3949 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 356/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3822 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 357/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3570 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 358/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4167 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 359/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.4038 - sparse_categorical_accuracy: 0.8583\n",
      "Epoch 360/500\n",
      "120/120 [==============================] - 0s 275us/sample - loss: 0.3636 - sparse_categorical_accuracy: 0.9417 - val_loss: 0.8138 - val_sparse_categorical_accuracy: 0.5333\n",
      "Epoch 361/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.4337 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 362/500\n",
      "120/120 [==============================] - 0s 100us/sample - loss: 0.3853 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 363/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3598 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 364/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3588 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 365/500\n",
      "120/120 [==============================] - 0s 92us/sample - loss: 0.4300 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 366/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3912 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 367/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3395 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 368/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4010 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 369/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3484 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 370/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3394 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 371/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3912 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 372/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3630 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 373/500\n",
      "120/120 [==============================] - 0s 100us/sample - loss: 0.3698 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 374/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3446 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 375/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3443 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 376/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.4100 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 377/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3428 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 378/500\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3732 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 379/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4839 - sparse_categorical_accuracy: 0.7917\n",
      "Epoch 380/500\n",
      "120/120 [==============================] - 0s 267us/sample - loss: 0.3773 - sparse_categorical_accuracy: 0.9083 - val_loss: 0.3185 - val_sparse_categorical_accuracy: 0.9667\n",
      "Epoch 381/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3405 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 382/500\n",
      "120/120 [==============================] - 0s 75us/sample - loss: 0.3427 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 383/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3512 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 384/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3712 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 385/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3541 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 386/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.4142 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 387/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3379 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 388/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3353 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 389/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3579 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 390/500\n",
      "120/120 [==============================] - 0s 108us/sample - loss: 0.3770 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 391/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3374 - sparse_categorical_accuracy: 0.9750\n",
      "Epoch 392/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3372 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 393/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3448 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 394/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3763 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 395/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3595 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 396/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3794 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 397/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3636 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 398/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3539 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 399/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3476 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 400/500\n",
      "120/120 [==============================] - 0s 283us/sample - loss: 0.3774 - sparse_categorical_accuracy: 0.9167 - val_loss: 0.3298 - val_sparse_categorical_accuracy: 0.9667\n",
      "Epoch 401/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3674 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 402/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4001 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 403/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3456 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 404/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3913 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 405/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3413 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 406/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3499 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 407/500\n",
      "120/120 [==============================] - 0s 108us/sample - loss: 0.4235 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 408/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3572 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 409/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3497 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 410/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3387 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 411/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3618 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 412/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3569 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 413/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3722 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 414/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.3410 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 415/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3571 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 416/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3866 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 417/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3416 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 418/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3459 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 419/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3700 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 420/500\n",
      "120/120 [==============================] - 0s 242us/sample - loss: 0.4336 - sparse_categorical_accuracy: 0.8917 - val_loss: 0.6770 - val_sparse_categorical_accuracy: 0.6000\n",
      "Epoch 421/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4614 - sparse_categorical_accuracy: 0.8333\n",
      "Epoch 422/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3684 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 423/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3927 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 424/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.3446 - sparse_categorical_accuracy: 0.968 - 0s 125us/sample - loss: 0.3352 - sparse_categorical_accuracy: 0.9833\n",
      "Epoch 425/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3867 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 426/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3432 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 427/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3410 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 428/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3425 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 429/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3393 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 430/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3373 - sparse_categorical_accuracy: 0.9750\n",
      "Epoch 431/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3624 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 432/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3596 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 433/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3558 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 434/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.3538 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 435/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3960 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 436/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3635 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 437/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4245 - sparse_categorical_accuracy: 0.8583\n",
      "Epoch 438/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3392 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 439/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3492 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 440/500\n",
      "120/120 [==============================] - 0s 250us/sample - loss: 0.3371 - sparse_categorical_accuracy: 0.9583 - val_loss: 0.3438 - val_sparse_categorical_accuracy: 1.0000\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 441/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3701 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 442/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3417 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 443/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3538 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 444/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3401 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 445/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3775 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 446/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3463 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 447/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.4087 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 448/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3768 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 449/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3658 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 450/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3906 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 451/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3470 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 452/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3467 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 453/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3642 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 454/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3548 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 455/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3693 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 456/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3876 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 457/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3648 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 458/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.4028 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 459/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3596 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 460/500\n",
      "120/120 [==============================] - 0s 258us/sample - loss: 0.4119 - sparse_categorical_accuracy: 0.8833 - val_loss: 0.5965 - val_sparse_categorical_accuracy: 0.6000\n",
      "Epoch 461/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3860 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 462/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4139 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 463/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3460 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 464/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3623 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 465/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3343 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 466/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3910 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 467/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4764 - sparse_categorical_accuracy: 0.8250\n",
      "Epoch 468/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3636 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 469/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3425 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 470/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3753 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 471/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4553 - sparse_categorical_accuracy: 0.8167\n",
      "Epoch 472/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.3502 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 473/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3874 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 474/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4106 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 475/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3458 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 476/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3452 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 477/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3426 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 478/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3489 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 479/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3354 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 480/500\n",
      "120/120 [==============================] - 0s 267us/sample - loss: 0.3357 - sparse_categorical_accuracy: 0.9833 - val_loss: 0.3341 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 481/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3943 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 482/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3412 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 483/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.3632 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 484/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3523 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 485/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3508 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 486/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3649 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 487/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.3386 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 488/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3598 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 489/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.4113 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 490/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4515 - sparse_categorical_accuracy: 0.8500\n",
      "Epoch 491/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.4595 - sparse_categorical_accuracy: 0.8500\n",
      "Epoch 492/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3822 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 493/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3504 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 494/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3589 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 495/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.5808 - sparse_categorical_accuracy: 0.7333\n",
      "Epoch 496/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3468 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 497/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3640 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 498/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3336 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 499/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3486 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 500/500\n",
      "120/120 [==============================] - 0s 250us/sample - loss: 0.3333 - sparse_categorical_accuracy: 0.9667 - val_loss: 0.4002 - val_sparse_categorical_accuracy: 1.0000\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<tensorflow.python.keras.callbacks.History at 0x1dd1233b108>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.fit(x_train, y_train, batch_size=32, epochs=500, validation_split=0.2, validation_freq=20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Model: \"sequential\"\n",
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "dense (Dense)                multiple                  15        \n",
      "=================================================================\n",
      "Total params: 15\n",
      "Trainable params: 15\n",
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n"
     ]
    }
   ],
   "source": [
    "model.summary()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 使用类class搭建神经网络-跳连的非顺序网络结构\n",
    "\n",
    "    class ModelName(Model):    #继承Tensorflow中的model类\n",
    "        def _init_(self):\n",
    "            super(ModelName,self)._init_()\n",
    "            self.d1 = Dense(3)#d1-单层网络，Dense(3)-三个神经元，全连接\n",
    "        def call(self,x):\n",
    "            y = self.d1(x)\n",
    "            return y\n",
    "    model = ModelName()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train on 120 samples, validate on 30 samples\n",
      "Epoch 1/500\n",
      "120/120 [==============================] - 0s 3ms/sample - loss: 2.1962 - sparse_categorical_accuracy: 0.3500\n",
      "Epoch 2/500\n",
      "120/120 [==============================] - 0s 108us/sample - loss: 0.8823 - sparse_categorical_accuracy: 0.6417\n",
      "Epoch 3/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 1.0519 - sparse_categorical_accuracy: 0.6500\n",
      "Epoch 4/500\n",
      "120/120 [==============================] - 0s 151us/sample - loss: 0.8097 - sparse_categorical_accuracy: 0.6333\n",
      "Epoch 5/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 1.0982 - sparse_categorical_accuracy: 0.6250\n",
      "Epoch 6/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.6229 - sparse_categorical_accuracy: 0.7167\n",
      "Epoch 7/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.9548 - sparse_categorical_accuracy: 0.6333\n",
      "Epoch 8/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.5668 - sparse_categorical_accuracy: 0.7417\n",
      "Epoch 9/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.6024 - sparse_categorical_accuracy: 0.7167\n",
      "Epoch 10/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.5653 - sparse_categorical_accuracy: 0.7750\n",
      "Epoch 11/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.5925 - sparse_categorical_accuracy: 0.7250\n",
      "Epoch 12/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.6456 - sparse_categorical_accuracy: 0.6667\n",
      "Epoch 13/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.5960 - sparse_categorical_accuracy: 0.7250\n",
      "Epoch 14/500\n",
      "120/120 [==============================] - 0s 208us/sample - loss: 0.6188 - sparse_categorical_accuracy: 0.6750\n",
      "Epoch 15/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.5207 - sparse_categorical_accuracy: 0.8417\n",
      "Epoch 16/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.5884 - sparse_categorical_accuracy: 0.6833\n",
      "Epoch 17/500\n",
      "120/120 [==============================] - 0s 217us/sample - loss: 0.4988 - sparse_categorical_accuracy: 0.8083\n",
      "Epoch 18/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.5115 - sparse_categorical_accuracy: 0.7583\n",
      "Epoch 19/500\n",
      "120/120 [==============================] - 0s 200us/sample - loss: 0.6111 - sparse_categorical_accuracy: 0.6917\n",
      "Epoch 20/500\n",
      "120/120 [==============================] - 0s 1ms/sample - loss: 0.7344 - sparse_categorical_accuracy: 0.6833 - val_loss: 0.6025 - val_sparse_categorical_accuracy: 0.5333\n",
      "Epoch 21/500\n",
      "120/120 [==============================] - 0s 131us/sample - loss: 0.4730 - sparse_categorical_accuracy: 0.8000\n",
      "Epoch 22/500\n",
      "120/120 [==============================] - 0s 108us/sample - loss: 0.6484 - sparse_categorical_accuracy: 0.6750\n",
      "Epoch 23/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.5528 - sparse_categorical_accuracy: 0.7917\n",
      "Epoch 24/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.7129 - sparse_categorical_accuracy: 0.6500\n",
      "Epoch 25/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.5139 - sparse_categorical_accuracy: 0.7667\n",
      "Epoch 26/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.4982 - sparse_categorical_accuracy: 0.8000\n",
      "Epoch 27/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 1.1382 - sparse_categorical_accuracy: 0.5917\n",
      "Epoch 28/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.5493 - sparse_categorical_accuracy: 0.7000\n",
      "Epoch 29/500\n",
      "120/120 [==============================] - 0s 233us/sample - loss: 0.6210 - sparse_categorical_accuracy: 0.7000\n",
      "Epoch 30/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.5422 - sparse_categorical_accuracy: 0.7000\n",
      "Epoch 31/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.4212 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 32/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.5288 - sparse_categorical_accuracy: 0.7000\n",
      "Epoch 33/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.6907 - sparse_categorical_accuracy: 0.6583\n",
      "Epoch 34/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.4772 - sparse_categorical_accuracy: 0.8083\n",
      "Epoch 35/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.5006 - sparse_categorical_accuracy: 0.718 - 0s 258us/sample - loss: 0.4436 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 36/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.5897 - sparse_categorical_accuracy: 0.7417\n",
      "Epoch 37/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4435 - sparse_categorical_accuracy: 0.8250\n",
      "Epoch 38/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.4061 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 39/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.4785 - sparse_categorical_accuracy: 0.7583\n",
      "Epoch 40/500\n",
      "120/120 [==============================] - 0s 242us/sample - loss: 0.4328 - sparse_categorical_accuracy: 0.8417 - val_loss: 0.5688 - val_sparse_categorical_accuracy: 0.6000\n",
      "Epoch 41/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.4749 - sparse_categorical_accuracy: 0.7917\n",
      "Epoch 42/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.5713 - sparse_categorical_accuracy: 0.7167\n",
      "Epoch 43/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.5949 - sparse_categorical_accuracy: 0.7000\n",
      "Epoch 44/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3894 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 45/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.6079 - sparse_categorical_accuracy: 0.7333\n",
      "Epoch 46/500\n",
      "120/120 [==============================] - 0s 208us/sample - loss: 0.6114 - sparse_categorical_accuracy: 0.6917\n",
      "Epoch 47/500\n",
      "120/120 [==============================] - 0s 200us/sample - loss: 0.4088 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 48/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4352 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 49/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.5262 - sparse_categorical_accuracy: 0.7417\n",
      "Epoch 50/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4200 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 51/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.6255 - sparse_categorical_accuracy: 0.6583\n",
      "Epoch 52/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.8264 - sparse_categorical_accuracy: 0.6833\n",
      "Epoch 53/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4714 - sparse_categorical_accuracy: 0.8250\n",
      "Epoch 54/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.5078 - sparse_categorical_accuracy: 0.7500\n",
      "Epoch 55/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.4240 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 56/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.4657 - sparse_categorical_accuracy: 0.8583\n",
      "Epoch 57/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3779 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 58/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3928 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 59/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3994 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 60/500\n",
      "120/120 [==============================] - 0s 233us/sample - loss: 0.4248 - sparse_categorical_accuracy: 0.8667 - val_loss: 0.9493 - val_sparse_categorical_accuracy: 0.5333\n",
      "Epoch 61/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.7443 - sparse_categorical_accuracy: 0.6833\n",
      "Epoch 62/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.3782 - sparse_categorical_accuracy: 0.937 - 0s 158us/sample - loss: 0.4022 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 63/500\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4407 - sparse_categorical_accuracy: 0.8500\n",
      "Epoch 64/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.4254 - sparse_categorical_accuracy: 0.8583\n",
      "Epoch 65/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.4211 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 66/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3679 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 67/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4784 - sparse_categorical_accuracy: 0.7833\n",
      "Epoch 68/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.6290 - sparse_categorical_accuracy: 0.6750\n",
      "Epoch 69/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3813 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 70/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3755 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 71/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3886 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 72/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4446 - sparse_categorical_accuracy: 0.8167\n",
      "Epoch 73/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3933 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 74/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.4546 - sparse_categorical_accuracy: 0.8583\n",
      "Epoch 75/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3730 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 76/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3745 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 77/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3885 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 78/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.6013 - sparse_categorical_accuracy: 0.7083\n",
      "Epoch 79/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3682 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 80/500\n",
      "120/120 [==============================] - 0s 250us/sample - loss: 0.3648 - sparse_categorical_accuracy: 0.9333 - val_loss: 0.3486 - val_sparse_categorical_accuracy: 0.9667\n",
      "Epoch 81/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.5549 - sparse_categorical_accuracy: 0.7333\n",
      "Epoch 82/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.4028 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 83/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3798 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 84/500\n",
      "120/120 [==============================] - 0s 200us/sample - loss: 0.3935 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 85/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4358 - sparse_categorical_accuracy: 0.8500\n",
      "Epoch 86/500\n",
      "120/120 [==============================] - 0s 166us/sample - loss: 0.4759 - sparse_categorical_accuracy: 0.8250\n",
      "Epoch 87/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4273 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 88/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.5257 - sparse_categorical_accuracy: 0.7500\n",
      "Epoch 89/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.5146 - sparse_categorical_accuracy: 0.8000\n",
      "Epoch 90/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4159 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 91/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4119 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 92/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3800 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 93/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4675 - sparse_categorical_accuracy: 0.7917\n",
      "Epoch 94/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.6290 - sparse_categorical_accuracy: 0.625 - 0s 150us/sample - loss: 0.4614 - sparse_categorical_accuracy: 0.8167\n",
      "Epoch 95/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3742 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 96/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3666 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 97/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3699 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 98/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3871 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 99/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3991 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 100/500\n",
      "120/120 [==============================] - 0s 267us/sample - loss: 0.3707 - sparse_categorical_accuracy: 0.9333 - val_loss: 0.3488 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 101/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3660 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 102/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3743 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 103/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.4448 - sparse_categorical_accuracy: 0.843 - 0s 150us/sample - loss: 0.4286 - sparse_categorical_accuracy: 0.8500\n",
      "Epoch 104/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4726 - sparse_categorical_accuracy: 0.8083\n",
      "Epoch 105/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3971 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 106/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3626 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 107/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3853 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 108/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4205 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 109/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4696 - sparse_categorical_accuracy: 0.8333\n",
      "Epoch 110/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4009 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 111/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4237 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 112/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3955 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 113/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3932 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 114/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3771 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 115/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.4146 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 116/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3639 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 117/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3559 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 118/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4085 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 119/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4038 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 120/500\n",
      "120/120 [==============================] - 0s 250us/sample - loss: 0.3898 - sparse_categorical_accuracy: 0.9083 - val_loss: 0.3566 - val_sparse_categorical_accuracy: 0.8667\n",
      "Epoch 121/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3968 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 122/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.5416 - sparse_categorical_accuracy: 0.8083\n",
      "Epoch 123/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4635 - sparse_categorical_accuracy: 0.8500\n",
      "Epoch 124/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3970 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 125/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4089 - sparse_categorical_accuracy: 0.8667\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 126/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3783 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 127/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4521 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 128/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3612 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 129/500\n",
      "120/120 [==============================] - 0s 108us/sample - loss: 0.3534 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 130/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3624 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 131/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3767 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 132/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.4185 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 133/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3814 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 134/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4230 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 135/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3636 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 136/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3685 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 137/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3573 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 138/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3876 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 139/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3797 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 140/500\n",
      "120/120 [==============================] - 0s 217us/sample - loss: 0.3610 - sparse_categorical_accuracy: 0.9167 - val_loss: 0.3956 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 141/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3889 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 142/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3711 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 143/500\n",
      "120/120 [==============================] - 0s 108us/sample - loss: 0.3936 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 144/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4222 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 145/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3865 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 146/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3884 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 147/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3573 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 148/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3567 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 149/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3535 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 150/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3700 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 151/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3543 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 152/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3525 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 153/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3923 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 154/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3644 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 155/500\n",
      "120/120 [==============================] - 0s 83us/sample - loss: 0.3598 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 156/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3713 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 157/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3599 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 158/500\n",
      "120/120 [==============================] - 0s 108us/sample - loss: 0.3831 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 159/500\n",
      "120/120 [==============================] - 0s 108us/sample - loss: 0.4198 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 160/500\n",
      "120/120 [==============================] - 0s 258us/sample - loss: 0.3753 - sparse_categorical_accuracy: 0.9083 - val_loss: 0.3352 - val_sparse_categorical_accuracy: 0.9667\n",
      "Epoch 161/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3496 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 162/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3552 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 163/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3585 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 164/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3939 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 165/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3553 - sparse_categorical_accuracy: 0.9750\n",
      "Epoch 166/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4774 - sparse_categorical_accuracy: 0.8167\n",
      "Epoch 167/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3585 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 168/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3671 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 169/500\n",
      "120/120 [==============================] - 0s 92us/sample - loss: 0.3551 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 170/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3679 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 171/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3501 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 172/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3583 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 173/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3850 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 174/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3711 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 175/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.5982 - sparse_categorical_accuracy: 0.7583\n",
      "Epoch 176/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.4060 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 177/500\n",
      "120/120 [==============================] - 0s 383us/sample - loss: 0.3808 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 178/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.3123 - sparse_categorical_accuracy: 1.000 - 0s 158us/sample - loss: 0.3528 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 179/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3529 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 180/500\n",
      "120/120 [==============================] - 0s 308us/sample - loss: 0.5415 - sparse_categorical_accuracy: 0.8000 - val_loss: 0.3710 - val_sparse_categorical_accuracy: 0.8667\n",
      "Epoch 181/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3991 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 182/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3712 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 183/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.4376 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 184/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3740 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 185/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3531 - sparse_categorical_accuracy: 0.9750\n",
      "Epoch 186/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4468 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 187/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3520 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 188/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3960 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 189/500\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3752 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 190/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3450 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 191/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3676 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 192/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3965 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 193/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4040 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 194/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3535 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 195/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3798 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 196/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3599 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 197/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3632 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 198/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3789 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 199/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3995 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 200/500\n",
      "120/120 [==============================] - 0s 217us/sample - loss: 0.3566 - sparse_categorical_accuracy: 0.9333 - val_loss: 0.3405 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 201/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3695 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 202/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3705 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 203/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3659 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 204/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3444 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 205/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.3843 - sparse_categorical_accuracy: 0.937 - 0s 108us/sample - loss: 0.3482 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 206/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3541 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 207/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3461 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 208/500\n",
      "120/120 [==============================] - 0s 200us/sample - loss: 0.4319 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 209/500\n",
      "120/120 [==============================] - 0s 108us/sample - loss: 0.3794 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 210/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.4089 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 211/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.4438 - sparse_categorical_accuracy: 0.8417\n",
      "Epoch 212/500\n",
      "120/120 [==============================] - 0s 108us/sample - loss: 0.3817 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 213/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3611 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 214/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3471 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 215/500\n",
      "120/120 [==============================] - 0s 108us/sample - loss: 0.3721 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 216/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3789 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 217/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.3600 - sparse_categorical_accuracy: 0.937 - 0s 158us/sample - loss: 0.3548 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 218/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3957 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 219/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3922 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 220/500\n",
      "120/120 [==============================] - 0s 292us/sample - loss: 0.4800 - sparse_categorical_accuracy: 0.8250 - val_loss: 0.3715 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 221/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3449 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 222/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3515 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 223/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3992 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 224/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4384 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 225/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4206 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 226/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3515 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 227/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3643 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 228/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3677 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 229/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3581 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 230/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3595 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 231/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4021 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 232/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3488 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 233/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.4141 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 234/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3510 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 235/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3453 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 236/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3707 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 237/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3780 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 238/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3629 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 239/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3612 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 240/500\n",
      "120/120 [==============================] - 0s 233us/sample - loss: 0.3823 - sparse_categorical_accuracy: 0.9333 - val_loss: 0.3478 - val_sparse_categorical_accuracy: 0.9000\n",
      "Epoch 241/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3899 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 242/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4695 - sparse_categorical_accuracy: 0.8167\n",
      "Epoch 243/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3549 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 244/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4236 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 245/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4944 - sparse_categorical_accuracy: 0.8583\n",
      "Epoch 246/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3543 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 247/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3524 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 248/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3801 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 249/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3485 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 250/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3434 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 251/500\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3485 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 252/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3454 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 253/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3492 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 254/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3815 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 255/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4077 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 256/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3796 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 257/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.3316 - sparse_categorical_accuracy: 0.968 - 0s 133us/sample - loss: 0.3603 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 258/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3593 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 259/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3550 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 260/500\n",
      "120/120 [==============================] - 0s 233us/sample - loss: 0.3702 - sparse_categorical_accuracy: 0.9333 - val_loss: 0.3728 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 261/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3443 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 262/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3642 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 263/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3592 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 264/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3484 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 265/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3374 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 266/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3543 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 267/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3952 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 268/500\n",
      "120/120 [==============================] - 0s 100us/sample - loss: 0.3469 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 269/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.4562 - sparse_categorical_accuracy: 0.8417\n",
      "Epoch 270/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3673 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 271/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3751 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 272/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4066 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 273/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3520 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 274/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3508 - sparse_categorical_accuracy: 0.9750\n",
      "Epoch 275/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.4247 - sparse_categorical_accuracy: 0.8500\n",
      "Epoch 276/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.5184 - sparse_categorical_accuracy: 0.8000\n",
      "Epoch 277/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3586 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 278/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4024 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 279/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.3105 - sparse_categorical_accuracy: 0.937 - 0s 175us/sample - loss: 0.3472 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 280/500\n",
      "120/120 [==============================] - 0s 267us/sample - loss: 0.3479 - sparse_categorical_accuracy: 0.9417 - val_loss: 0.5195 - val_sparse_categorical_accuracy: 0.6667\n",
      "Epoch 281/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.5396 - sparse_categorical_accuracy: 0.7750\n",
      "Epoch 282/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3576 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 283/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4066 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 284/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3588 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 285/500\n",
      "120/120 [==============================] - 0s 108us/sample - loss: 0.4913 - sparse_categorical_accuracy: 0.8417\n",
      "Epoch 286/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3891 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 287/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3614 - sparse_categorical_accuracy: 0.9750\n",
      "Epoch 288/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3402 - sparse_categorical_accuracy: 0.9833\n",
      "Epoch 289/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3814 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 290/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3901 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 291/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3999 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 292/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.3229 - sparse_categorical_accuracy: 1.000 - 0s 158us/sample - loss: 0.3704 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 293/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3493 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 294/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3948 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 295/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4169 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 296/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3815 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 297/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3795 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 298/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3618 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 299/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3718 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 300/500\n",
      "120/120 [==============================] - 0s 292us/sample - loss: 0.3682 - sparse_categorical_accuracy: 0.9333 - val_loss: 0.3514 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 301/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3612 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 302/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4212 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 303/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3701 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 304/500\n",
      "120/120 [==============================] - 0s 92us/sample - loss: 0.3714 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 305/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3543 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 306/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3445 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 307/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3452 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 308/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3441 - sparse_categorical_accuracy: 0.9833\n",
      "Epoch 309/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3593 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 310/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3656 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 311/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3575 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 312/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3515 - sparse_categorical_accuracy: 0.9750\n",
      "Epoch 313/500\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "120/120 [==============================] - 0s 108us/sample - loss: 0.3453 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 314/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3416 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 315/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3368 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 316/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4223 - sparse_categorical_accuracy: 0.8917\n",
      "Epoch 317/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3694 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 318/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3409 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 319/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3643 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 320/500\n",
      "120/120 [==============================] - 0s 250us/sample - loss: 0.3563 - sparse_categorical_accuracy: 0.9500 - val_loss: 0.6103 - val_sparse_categorical_accuracy: 0.6000\n",
      "Epoch 321/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3852 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 322/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3413 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 323/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3346 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 324/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3535 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 325/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3591 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 326/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3533 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 327/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3399 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 328/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4023 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 329/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3758 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 330/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3763 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 331/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3627 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 332/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3408 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 333/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3571 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 334/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3856 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 335/500\n",
      "120/120 [==============================] - 0s 166us/sample - loss: 0.4155 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 336/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.5168 - sparse_categorical_accuracy: 0.7917\n",
      "Epoch 337/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3682 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 338/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3524 - sparse_categorical_accuracy: 0.9750\n",
      "Epoch 339/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.3811 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 340/500\n",
      "120/120 [==============================] - 0s 258us/sample - loss: 0.3978 - sparse_categorical_accuracy: 0.8833 - val_loss: 0.4761 - val_sparse_categorical_accuracy: 0.8000\n",
      "Epoch 341/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3589 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 342/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3607 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 343/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3863 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 344/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3998 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 345/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3920 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 346/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4703 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 347/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4195 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 348/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3537 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 349/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3494 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 350/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3398 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 351/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.3869 - sparse_categorical_accuracy: 0.937 - 0s 150us/sample - loss: 0.3429 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 352/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3463 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 353/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3714 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 354/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3735 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 355/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3949 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 356/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3822 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 357/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3570 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 358/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4167 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 359/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.4038 - sparse_categorical_accuracy: 0.8583\n",
      "Epoch 360/500\n",
      "120/120 [==============================] - 0s 283us/sample - loss: 0.3636 - sparse_categorical_accuracy: 0.9417 - val_loss: 0.8138 - val_sparse_categorical_accuracy: 0.5333\n",
      "Epoch 361/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4337 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 362/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.3853 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 363/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3598 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 364/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3588 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 365/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4300 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 366/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3912 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 367/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3395 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 368/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.4010 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 369/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3484 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 370/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3394 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 371/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3912 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 372/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3630 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 373/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3698 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 374/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3446 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 375/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3443 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 376/500\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "120/120 [==============================] - 0s 175us/sample - loss: 0.4100 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 377/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3428 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 378/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3732 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 379/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4839 - sparse_categorical_accuracy: 0.7917\n",
      "Epoch 380/500\n",
      "120/120 [==============================] - 0s 258us/sample - loss: 0.3773 - sparse_categorical_accuracy: 0.9083 - val_loss: 0.3185 - val_sparse_categorical_accuracy: 0.9667\n",
      "Epoch 381/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3405 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 382/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3427 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 383/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3512 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 384/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3712 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 385/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3541 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 386/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4142 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 387/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3379 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 388/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3353 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 389/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3579 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 390/500\n",
      "120/120 [==============================] - 0s 200us/sample - loss: 0.3770 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 391/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3374 - sparse_categorical_accuracy: 0.9750\n",
      "Epoch 392/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3372 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 393/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3448 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 394/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3763 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 395/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3595 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 396/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3794 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 397/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3636 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 398/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3539 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 399/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3476 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 400/500\n",
      "120/120 [==============================] - 0s 258us/sample - loss: 0.3774 - sparse_categorical_accuracy: 0.9167 - val_loss: 0.3298 - val_sparse_categorical_accuracy: 0.9667\n",
      "Epoch 401/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3674 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 402/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4001 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 403/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3456 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 404/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3913 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 405/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3413 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 406/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3499 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 407/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4235 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 408/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3572 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 409/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3497 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 410/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3387 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 411/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3618 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 412/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.3569 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 413/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3722 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 414/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3410 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 415/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3571 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 416/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3866 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 417/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3416 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 418/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3459 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 419/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3700 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 420/500\n",
      "120/120 [==============================] - 0s 291us/sample - loss: 0.4336 - sparse_categorical_accuracy: 0.8917 - val_loss: 0.6770 - val_sparse_categorical_accuracy: 0.6000\n",
      "Epoch 421/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4614 - sparse_categorical_accuracy: 0.8333\n",
      "Epoch 422/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3684 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 423/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3927 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 424/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3352 - sparse_categorical_accuracy: 0.9833\n",
      "Epoch 425/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3867 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 426/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3432 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 427/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3410 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 428/500\n",
      "120/120 [==============================] - 0s 233us/sample - loss: 0.3425 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 429/500\n",
      "120/120 [==============================] - 0s 192us/sample - loss: 0.3393 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 430/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3373 - sparse_categorical_accuracy: 0.9750\n",
      "Epoch 431/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3624 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 432/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3596 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 433/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3558 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 434/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3538 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 435/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3960 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 436/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3635 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 437/500\n",
      "120/120 [==============================] - 0s 83us/sample - loss: 0.4245 - sparse_categorical_accuracy: 0.8583\n",
      "Epoch 438/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3392 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 439/500\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3492 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 440/500\n",
      "120/120 [==============================] - 0s 291us/sample - loss: 0.3371 - sparse_categorical_accuracy: 0.9583 - val_loss: 0.3438 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 441/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3701 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 442/500\n",
      "120/120 [==============================] - 0s 200us/sample - loss: 0.3417 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 443/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3538 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 444/500\n",
      "120/120 [==============================] - ETA: 0s - loss: 0.2886 - sparse_categorical_accuracy: 1.000 - 0s 150us/sample - loss: 0.3401 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 445/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3775 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 446/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3463 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 447/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4087 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 448/500\n",
      "120/120 [==============================] - 0s 208us/sample - loss: 0.3768 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 449/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3658 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 450/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3906 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 451/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3470 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 452/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3467 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 453/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3642 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 454/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3548 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 455/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3693 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 456/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3876 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 457/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3648 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 458/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.4028 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 459/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3596 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 460/500\n",
      "120/120 [==============================] - 0s 233us/sample - loss: 0.4119 - sparse_categorical_accuracy: 0.8833 - val_loss: 0.5965 - val_sparse_categorical_accuracy: 0.6000\n",
      "Epoch 461/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3860 - sparse_categorical_accuracy: 0.8833\n",
      "Epoch 462/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4139 - sparse_categorical_accuracy: 0.8750\n",
      "Epoch 463/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3460 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 464/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3623 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 465/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3343 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 466/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3910 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 467/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.4764 - sparse_categorical_accuracy: 0.8250\n",
      "Epoch 468/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3636 - sparse_categorical_accuracy: 0.9250\n",
      "Epoch 469/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3425 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 470/500\n",
      "120/120 [==============================] - 0s 117us/sample - loss: 0.3753 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 471/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.4553 - sparse_categorical_accuracy: 0.8167\n",
      "Epoch 472/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3502 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 473/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3874 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 474/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.4106 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 475/500\n",
      "120/120 [==============================] - 0s 200us/sample - loss: 0.3458 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 476/500\n",
      "120/120 [==============================] - 0s 183us/sample - loss: 0.3452 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 477/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3426 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 478/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3489 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 479/500\n",
      "120/120 [==============================] - 0s 167us/sample - loss: 0.3354 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 480/500\n",
      "120/120 [==============================] - 0s 275us/sample - loss: 0.3357 - sparse_categorical_accuracy: 0.9833 - val_loss: 0.3341 - val_sparse_categorical_accuracy: 1.0000\n",
      "Epoch 481/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3943 - sparse_categorical_accuracy: 0.9000\n",
      "Epoch 482/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3412 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 483/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.3632 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 484/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3523 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 485/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3508 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 486/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.3649 - sparse_categorical_accuracy: 0.9167\n",
      "Epoch 487/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3386 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 488/500\n",
      "120/120 [==============================] - 0s 200us/sample - loss: 0.3598 - sparse_categorical_accuracy: 0.9333\n",
      "Epoch 489/500\n",
      "120/120 [==============================] - 0s 133us/sample - loss: 0.4113 - sparse_categorical_accuracy: 0.8667\n",
      "Epoch 490/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.4515 - sparse_categorical_accuracy: 0.8500\n",
      "Epoch 491/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.4595 - sparse_categorical_accuracy: 0.8500\n",
      "Epoch 492/500\n",
      "120/120 [==============================] - 0s 150us/sample - loss: 0.3822 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 493/500\n",
      "120/120 [==============================] - 0s 175us/sample - loss: 0.3504 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 494/500\n",
      "120/120 [==============================] - 0s 191us/sample - loss: 0.3589 - sparse_categorical_accuracy: 0.9083\n",
      "Epoch 495/500\n",
      "120/120 [==============================] - 0s 158us/sample - loss: 0.5808 - sparse_categorical_accuracy: 0.7333\n",
      "Epoch 496/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3468 - sparse_categorical_accuracy: 0.9417\n",
      "Epoch 497/500\n",
      "120/120 [==============================] - 0s 142us/sample - loss: 0.3640 - sparse_categorical_accuracy: 0.9500\n",
      "Epoch 498/500\n",
      "120/120 [==============================] - 0s 125us/sample - loss: 0.3336 - sparse_categorical_accuracy: 0.9667\n",
      "Epoch 499/500\n",
      "120/120 [==============================] - 0s 216us/sample - loss: 0.3486 - sparse_categorical_accuracy: 0.9583\n",
      "Epoch 500/500\n",
      "120/120 [==============================] - 0s 325us/sample - loss: 0.3333 - sparse_categorical_accuracy: 0.9667 - val_loss: 0.4002 - val_sparse_categorical_accuracy: 1.0000\n",
      "Model: \"iris_model\"\n",
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "dense_1 (Dense)              multiple                  15        \n",
      "=================================================================\n",
      "Total params: 15\n",
      "Trainable params: 15\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n"
     ]
    }
   ],
   "source": [
    "import tensorflow as tf\n",
    "from tensorflow.keras.layers import Dense\n",
    "from tensorflow.keras import Model\n",
    "from sklearn import datasets\n",
    "import numpy as np\n",
    "\n",
    "x_train = datasets.load_iris().data\n",
    "y_train = datasets.load_iris().target\n",
    "\n",
    "np.random.seed(116)\n",
    "np.random.shuffle(x_train)\n",
    "np.random.seed(116)\n",
    "np.random.shuffle(y_train)\n",
    "tf.random.set_seed(116)\n",
    "\n",
    "#########################################\n",
    "class IrisModel(Model):\n",
    "    def __init__(self):\n",
    "        super(IrisModel, self).__init__()\n",
    "        self.d1 = Dense(3, activation='softmax', kernel_regularizer=tf.keras.regularizers.l2())\n",
    "\n",
    "    def call(self, x):\n",
    "        y = self.d1(x)\n",
    "        return y\n",
    "\n",
    "model = IrisModel()\n",
    "#########################################\n",
    "\n",
    "model.compile(optimizer=tf.keras.optimizers.SGD(lr=0.1),\n",
    "              loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=False),\n",
    "              metrics=['sparse_categorical_accuracy'])\n",
    "\n",
    "model.fit(x_train, y_train, batch_size=32, epochs=500, validation_split=0.2, validation_freq=20)\n",
    "model.summary()\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
